package com.cinema.cli;

import java.io.*;

public class SessionManager {
    private static final String SESSION_FILE = ".session";

    public static void saveSession(String userId) throws IOException {
        try (BufferedWriter writer = new BufferedWriter(new FileWriter(SESSION_FILE))) {
            writer.write(userId);
            writer.flush();
        }
    }

    public static String loadSession() throws IOException {
        File file = new File(SESSION_FILE);
        if (!file.exists()) {
            return null;
        }
        try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
            return reader.readLine();
        }
    }

    public static void clearSession() {
        File file = new File(SESSION_FILE);
        if (file.exists()) file.delete();
    }
} 